# -*- coding: utf-8 -*-
import os
import importlib.util


def routes():
    modules     = []
    current_dir = os.path.dirname(os.path.abspath(__file__))

    for file in os.listdir(current_dir):
        if not (file.endswith(".py") and "_" not in file):
            continue

        module_name = os.path.splitext(file)[0]
        module_path = os.path.join(current_dir, file)

        spec   = importlib.util.spec_from_file_location(module_name, module_path)
        module = importlib.util.module_from_spec(spec)

        spec.loader.exec_module(module)
        route = getattr(module, module_name, None)

        if route == None:
            continue

        modules.append(route)

    return modules
